<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #drawing {
      border: 10px solid #ccc;
    }
  </style>
</head>
<body>
  <canvas id="drawing" width="200" height="200"></canvas>
  
  <script>
    // 这里直接用 drawing 就可以访问到 canvas 元素了
    // 如果dom元素的id名称不和js内置属性或全局变量重名的话，该名称自动成为window对象的属性
    let context = drawing.getContext("2d");// 设置阴影
    context.shadowOffsetX = 5;
    context.shadowOffsetY = 5;
    context.shadowBlur = 4;
    context.shadowColor = "rgba(0, 0, 0, 0.5)";
    // 绘制红色矩形
    context.fillStyle = "#ff0000";
    context.fillRect(10, 10, 50, 50);
    // 绘制蓝色矩形
    context.fillStyle = "rgba(0,0,255,1)";
    context.fillRect(30, 30, 50, 50);
  </script>
</body>
</html>